<?php
/* @var $this DownloadController */
/* @var $model Article */
/* @var $form CActiveForm */
?>
<style type="text/css">
    .multi-img-details{padding:10px 0px;}
    .multi-img-details ul{padding:0px;margin:0px;}
    .multi-img-details .multi-item{padding:0px;list-style:none;display:inline-grid;}
    .multi-img-details .multi-item .img-thumbnail{width:80px;height:80px;}
    .multi-img-details .multi-item .close{color:#f00;text-align:center;}
</style>
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'article-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
    'enableAjaxValidation'=>false,
    /**
     * activeFileField()方法为一个模型属性生成一个文件输入框。
     * 注意，你必须设置表单的‘enctype’属性为‘multipart/form-data’。
     * 表单被提交后，上传的文件信息可以通过$_FILES[$name]来获得 (请参阅 PHP documentation).
     */
    'htmlOptions'=>array('class'=>'form-horizontal', 'enctype'=>'multipart/form-data'),
)); ?>
<?php //var_dump($model->articleTags);?>
	<?php echo $form->errorSummary($model); ?>
    <div class="col-md-7">
        <div class="form-group">
            <?php echo $form->labelEx($model,'title',array('class'=>'col-sm-2 control-label')); ?>
            <div class="col-sm-10">
                <?php echo $form->textField($model,'title',array('class'=>'form-control')); ?>
            </div>
        </div>
        <div class="form-group">
            <?php echo $form->labelEx($model,'sub_title',array('class'=>'col-sm-2 control-label')); ?>
            <div class="col-sm-10">
                <?php echo $form->textField($model,'sub_title',array('class'=>'form-control')); ?>
            </div>
        </div>

        <div class="form-group">
            <?php echo $form->labelEx($model,'summary',array('class'=>'col-sm-2 control-label')); ?>
            <div class="col-sm-10">
                <?php echo $form ->textArea( $model , 'summary' ,array('class'=>'form-control'));?>
            </div>
        </div>
        <div class="form-group">
            <?php echo $form->labelEx($model,'thumb',array('class'=>'col-sm-2 control-label')); ?>
            <div class="col-sm-10 image">

                <?php echo $form->fileField($model,'thumb',array('class'=>'form-control pretty-file img-responsive')); ?>

                <!--<input id="ytArticle_thumb" type="hidden" value="<?/*=$model->thumb*/?>" name="Article[thumb]" />
                <input class="form-control pretty-file img-responsive" name="Article[thumb]" id="Article_thumb" type="file" value="<?/*=$model->thumb*/?>"/>-->

                <div style='position:relative'>
                    <img class="" src="<?php echo $model->thumb;?>" alt="" style="max-width:120px;max-height:120px" text="选择图片" nonePicUrl="<?=Yii::app()->baseUrl;?>/resource/backend/images/none.jpg">
                    <?php if(!$model->isNewRecord && $model->thumb!='resource/frontend/images/none.jpg'){?>
                    <div onclick="$(this).parents('.image').find('input[type=hidden]').val(0);$(this).prev().attr('src', '<?=Yii::app()->baseUrl;?>/resource/backend/images/none.jpg');$(this).remove()" style='position:absolute;width:50px;padding:5px 3px 3px 5px;top:5px;left:6px;background:black;opacity:0.6;color:white;cursor:pointer'>
                        <i class='fa fa-trash thumbDelete' aria-hidden='true'> 删除</i>
                    </div>
                    <?php }?>
                </div>
            </div>
        </div>
        <div class="form-group">
            <?php echo $form->labelEx($model,'cover',array('class'=>'col-sm-2 control-label')); ?>
            <div class="col-sm-10 image">
                <input id="ytArticle_cover" type="hidden" value="<?=$model->cover?>" name="Article[cover]" />
                <input class="form-control pretty-file img-responsive" name="Article[cover]" id="Article_cover" type="file" value="<?=$model->cover?>"/>

                <div style='position:relative'>
                    <img class="" src="<?php echo $model->cover;?>" alt="" style="max-width:120px;max-height:120px" text="选择图片" nonePicUrl="<?=Yii::app()->baseUrl;?>/resource/backend/images/none.jpg">
                    <?php if(!$model->isNewRecord && $model->cover != 'resource/frontend/images/none.jpg'){?>
                        <div onclick="$(this).parents('.image').find('input[type=hidden]').val(0);$(this).prev().attr('src', '<?=Yii::app()->baseUrl;?>/resource/backend/images/none.jpg');$(this).remove()" style='position:absolute;width:50px;padding:5px 3px 3px 5px;top:5px;left:6px;background:black;opacity:0.6;color:white;cursor:pointer'>
                            <i class='fa fa-trash coverDelete' aria-hidden='true'> 删除</i>
                        </div>
                    <?php }?>
                </div>
            </div>
        </div>
        <!-- 多图上传 -->
        <div class="form-group">
            <?php echo $form->labelEx($model,'images',array('class'=>'col-sm-2 control-label')); ?>
            <div class="col-sm-10">

                <input id="Article_images" type="file" name="Article[images][]" class="form-control"/>
                <?php
                /*$this->widget('BackendMultiFileUpload', array(
                    'model'=>$model,
                    //'name' => 'images',
                    'attribute' => 'images',
                    'accept' => 'jpeg|jpg|gif|png', // useful for verifying files
                    'duplicate' => 'Duplicate file!', // useful, i think
                    'options'=>array(
                         'onFileSelect'=>'function(e, v, m){ alert("onFileSelect - "+v) }',
                         'afterFileSelect'=>'function(e, v, m){ alert("afterFileSelect - "+v) }',
                         'onFileAppend'=>'function(e, v, m){ alert("onFileAppend - "+v) }',
                         'afterFileAppend'=>'function(e, v, m){ alert("afterFileAppend - "+v) }',
                         'onFileRemove'=>'function(e, v, m){ alert("onFileRemove - "+v) }',
                         'afterFileRemove'=>'function(e, v, m){ alert("afterFileRemove - "+v) }',
                    ),
                    'htmlOptions'=>array('class'=>'form-control'),
                    'denied' => 'Invalid file type', // useful, i think
                ));*/
                ?>
                <div class="input-group multi-img-details">
                    <ul>
                    <?php if($model->images):$image = explode(',',$model->images);foreach ($image as $value){?>
                    <li class="multi-item">
                        <a href="<?=$value;?>" target="_blank"><img class="img-responsive img-thumbnail cus-img" src="<?=$value;?>" alt=""></a>
                        <input type="hidden" name="Article[images][]" value="<?=$value;?>">
                        <em class="close delMultiImage" title="删除这张图片">x</em>
                    </li>
                    <?php } endif?>
                    </ul>
                </div>

            </div>
        </div>
        <div class="form-group">
            <?php echo $form->labelEx($model,'content',array('class'=>'col-sm-2 control-label')); ?>
            <div class="col-sm-10">
                <?php //echo $form ->textArea( $model , 'content', array('class'=>'form-control','rows'=>10));?>

                <?php
                $this->widget('ext.ueditor.UeditorWidget',
                    array(
                        'model' => $model,
                        'attribute' => 'content',
                        'config'=>array(
                            'serverUrl' => Yii::app()->createUrl('backend/editor/index'),//指定serverUrl
                            'toolbars'=>array(
                                //array('source','link','bold','italic','underline','forecolor','superscript','insertimage','spechars','blockquote')
                            ),
                            'initialFrameHeight'=>'350',
                            'initialFrameWidth'=>'100%'
                        ),
                        'htmlOptions' => array('rows'=>3,'class'=>'')
                    )
                );
                ?>

            </div>
        </div>
    </div>
    <div class="col-md-5">
        <div class="form-group">
            <?php echo $form->labelEx($model,'cid',array('class'=>'col-sm-2 control-label')); ?>
            <div class="col-sm-10">
                <?php echo $form->dropDownList($model, 'cid', Category::getCategoriesName(),array('class'=>'chosen-select form-control') )?>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">属性</label>
            <div class="col-sm-10">
                <?php echo $form ->checkBox( $model , 'flag_headline' , array('class'=>'icheckbox_minimal-blue'));?> 头条 &nbsp;
                <?php echo $form ->checkBox( $model , 'flag_recommend' , array('class'=>'icheckbox_minimal-blue'));?> 推荐 &nbsp;
                <?php echo $form ->checkBox( $model , 'flag_slide_show' , array('class'=>'icheckbox_minimal-blue'));?> 幻灯 &nbsp;
                <?php echo $form ->checkBox( $model , 'flag_special_recommend' , array('class'=>'icheckbox_minimal-blue'));?> 特别推荐 &nbsp;
                <?php echo $form ->checkBox( $model , 'flag_roll' , array('class'=>'icheckbox_minimal-blue'));?> 滚动 &nbsp;
                <?php echo $form ->checkBox( $model , 'flag_bold' , array('class'=>'icheckbox_minimal-blue'));?> 加粗 &nbsp;
                <?php echo $form ->checkBox( $model , 'flag_picture' , array('class'=>'icheckbox_minimal-blue'));?> 图片 &nbsp;
            </div>
        </div>
        <div class="form-group">
            <?php echo $form->labelEx($model,'seo_title',array('class'=>'col-sm-2 control-label')); ?>
            <div class="col-sm-10">
                <?php echo $form ->textField( $model , 'seo_title', array('class'=>'form-control'));?>
            </div>
        </div>
        <div class="form-group">
            <?php echo $form->labelEx($model,'seo_keywords',array('class'=>'col-sm-2 control-label')); ?>
            <div class="col-sm-10">
                <?php echo $form ->textField( $model , 'seo_keywords', array('class'=>'form-control'));?>
            </div>
        </div>
        <div class="form-group">
            <?php echo $form->labelEx($model,'seo_description',array('class'=>'col-sm-2 control-label')); ?>
            <div class="col-sm-10">
                <?php echo $form ->textField( $model , 'seo_description', array('class'=>'form-control'));?>
            </div>
        </div>
        <div class="form-group">
            <div class="col-xs-4">
                <?php echo $form->labelEx($model,'status',array('class'=>'col-sm-4 control-label')); ?>
                <div class="col-sm-8">
                    <?php echo $form ->dropDownList($model, 'status' ,array('1'=>'发布' , '0'=>'草稿' ), array('class'=>'form-control'));?>
                </div>
            </div>
            <div class="col-xs-4">
                <?php echo $form->labelEx($model,'can_comment',array('class'=>'col-sm-4 control-label')); ?>
                <div class="col-sm-8">
                    <?php echo $form ->dropDownList($model, 'can_comment' ,array('1'=>'是' , '0'=>'否' ), array('class'=>'form-control'));?>
                </div>
            </div>
            <div class="col-xs-4">
                <?php echo $form->labelEx($model,'visibility',array('class'=>'col-sm-4 control-label')); ?>
                <div class="col-sm-8">
                    <?php echo $form ->dropDownList($model, 'visibility' ,array('1'=>'公开', '2'=>'回复', '3'=>'密码', '4'=>'登录'), array('class'=>'form-control'));?>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">标签</label>
            <div class="col-sm-10">
                <?php echo $form ->textField( $model , 'tag', array('class'=>'form-control'));?>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">排序</label>
            <div class="col-sm-10">
                <?php echo $form ->textField( $model , 'sort', array('class'=>'form-control'));?>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">模板</label>
            <div class="col-sm-10">
                <?php echo $form ->textField($model, 'template', array('class'=>'form-control'));?>
            </div>
        </div>
        <input type="hidden" name="oldThumb" value="<?=$model->thumb?>">
        <input type="hidden" name="oldCover" value="<?=$model->cover?>">
        <div class="hr hr-18 dotted"></div>
        <div class="clearfix">
            <div class="col-md-offset-2 col-md-10">
                <button class="btn btn-white btn-info btn-bold btn-round" type="submit"><i class="ace-icon fa fa-floppy-o bigger-120 blue"></i>保存</button>
                &nbsp;
                <button class="btn btn-white btn-default btn-round" type="reset"><i class="ace-icon fa fa-times red2"></i>取消</button>
            </div>
        </div>
    </div>

<?php $this->endWidget(); ?>

</div><!-- form -->
